package cn.school.controller.publicPhone;

import cn.school.common.api.CommonResult;
import cn.school.publicPhone.service.PhoneLoginService;
import cn.school.publicPhone.service.StudentCallService;
import cn.school.publicPhone.vo.StudentCallRecords;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 公话登录
 */
@RestController
@RequestMapping("/phone")
public class PublicPhoneLoginController {

    @Resource
    private PhoneLoginService phoneLoginService;
    
    @Resource
    private StudentCallService studentCallService;

    @ApiOperation(value = "autoFaceLogin => 扫描脸部自动登录")
    @PostMapping(value = "/autoFaceLogin")
    public CommonResult<Map<String, Object>> autoFaceLogin(@RequestBody Map<String,String> paramMap, HttpServletRequest request){
        Map<String, Object> map = phoneLoginService.autoFaceLogin(paramMap.get("imageBase64"),request);

        return CommonResult.success(map);
    }
    
    /**
     * 保存通话记录
     *
     * @return
     * @author alex
     * @date 2023/6/25 8:25
     */
    @PostMapping(value = "/saveCallRecords")
    public CommonResult<Integer> saveStudentCallRecorder(@RequestBody StudentCallRecords studentCallRecords) {
        int callRecords = studentCallService.saveStudentCallRecords(studentCallRecords);
        return CommonResult.success(callRecords);
    }
    

//    @ApiOperation(value = "注册人脸到百度")
//    @PostMapping(value = "/faceRegisterToBaidu")
//    public CommonResult<Map<String, String>> faceRegisterToBaidu(@RequestBody Map<String,String> paramMap){
//        String num  =  phoneLoginService.faceRegisterToBaidu(paramMap);
//        if(StringUtils.isEmpty(num)){
//            return CommonResult.success();
//        }
//        return CommonResult.failed();
//    }
//
//    @ApiOperation(value = "修改人脸到百度")
//    @PostMapping(value = "/updateFaceToBaidu")
//    public CommonResult<Map<String, String>> updateFaceRegisterToBaidu(@RequestBody Map<String,String> paramMap){
//        String num  = phoneLoginService.updateFaceRegisterToBaidu(paramMap);
//        if(StringUtils.isEmpty(num)){
//            return CommonResult.success();
//        }
//        return CommonResult.failed();
//    }




}
